import React, { useRef, useCallback, useEffect } from "react";
import {getCaptchaCode} from '@/api/common';

const useCaptcha = () => {
  const captchaRef = useRef();

  const getCaptcha = useCallback(async () => {
    const {data} = await getCaptchaCode();
    captchaRef.current.innerHTML = data;
  }, []);

  useEffect(() => {
    getCaptcha();
  }, []);


  return {
    captchaRef,
    getCaptcha
  };
};


export default useCaptcha;
